<?php

namespace app\controllers;

use Yii;
use yii\web\Controller;
use yii\web\Response;

class BaseController extends Controller
{
    public $enableCsrfValidation = false;
    public function init()
    {
        parent::init();
        // Yii::$app->response->format= yii\web\Response::FORMAT_JSON;
    }
    public function behaviors()
    {
        // Yii::$app->response->format=Response::FORMAT_JSON;
        return [
            # 命名行为
            'bootstrap' => [//启动引导的响应格式
                'class'            => 'yii\filters\ContentNegotiator',
                'formats'          => [
                    'application/json' => Response::FORMAT_JSON,
                    'application/xml'  => Response::FORMAT_XML,
                ],
                'languages'        => ['cn'],
            ],
        ];
    }
}
